package com.lzmpt.imchat.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.byt.framlib.commonutils.DisplayUtil;
import com.byt.framlib.commonwidget.vertical.VerticalRecyclerView;
import com.lzmpt.imchat.R;
import com.lzmpt.imchat.adapter.MainFuctionAdapter;
import com.lzmpt.imchat.adapter.ThreeAdapter;
import com.lzmpt.imchat.adapter.TwoAdapter;
import com.lzmpt.imchat.widget.RecyclerViewSpacesItemDecoration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;

public class JuliFragment extends Fragment {
    private View view;
    private EditText etName;
    private VerticalRecyclerView rvOne;
    private GridLayoutManager gv_one;
    private List<String> datas;
    private MainFuctionAdapter mainFuctionAdapter;
    private VerticalRecyclerView rvTwo;
    private VerticalRecyclerView rvThree;
    private TwoAdapter twoAdapter;
    private LinearLayoutManager ll_h;
    private ThreeAdapter threeAdapter;
    private LinearLayoutManager ll_v;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = LayoutInflater.from(getActivity())
                .inflate(R.layout.fragment_juli ,container, false);
        etName = (EditText)view. findViewById(R.id.et_name);
        rvOne = (VerticalRecyclerView) view.findViewById(R.id.rv_one);
        gv_one = new GridLayoutManager(getActivity(), 5);
        HashMap<String, Integer> oneMap = new HashMap<>();
        oneMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, DisplayUtil.dip2px( 20));//
        rvOne.addItemDecoration(new RecyclerViewSpacesItemDecoration(oneMap));

        rvTwo = (VerticalRecyclerView) view.findViewById(R.id.rv_two);
        rvThree = (VerticalRecyclerView) view.findViewById(R.id.rv_three);

        rvOne.setLayoutManager(gv_one);
        datas = new ArrayList<>();
        datas.add("上游");
        datas.add("终端");
        datas.add("下游");
        datas.add("农业");
        datas.add("招聘");
        datas.add("二手");
        datas.add("物流");
        datas.add("咨询");
        datas.add("直播");
        datas.add("6.9特价");
        mainFuctionAdapter = new MainFuctionAdapter(getActivity(), datas);
        rvOne.setAdapter(mainFuctionAdapter);
        ll_h = new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL,false);
        rvTwo.setLayoutManager(ll_h);

        HashMap<String, Integer> twoMap = new HashMap<>();
        twoMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION, DisplayUtil.dip2px( 10));//
        rvTwo.addItemDecoration(new RecyclerViewSpacesItemDecoration(twoMap));


        twoAdapter = new TwoAdapter(getActivity(),datas);
        rvTwo.setAdapter(twoAdapter);

        ll_v = new LinearLayoutManager(getActivity());
        rvThree.setLayoutManager(ll_v);


        HashMap<String, Integer> threeMap = new HashMap<>();
        threeMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, DisplayUtil.dip2px( 10));//
        rvThree.addItemDecoration(new RecyclerViewSpacesItemDecoration(threeMap));


        threeAdapter = new ThreeAdapter(getActivity(),datas);
        rvThree.setAdapter(threeAdapter);

        return view;
    }
}
